import { createBrowserRouter as createRouter } from 'react-router-dom'
import App from '@/views/App';
// import Home from '@/views/Home';
// import Fast from '@/views/Fast';
import Mine from '@/views/Mine';
import Select from '@/views/Select';
import Practice from '@/views/Practice';
import Subjects from '@/views/Subjects';
import Login from '@/views/Login';
import { lazy } from 'react';

// 实现路由懒加载
// 1. 使用lazy方法将组件懒加载进来
const Fast = lazy(() => import('@/views/Fast/index'))
const Home = lazy(() => import('@/views/Home/index'))
// 2. 在路由外使用 suspance 进行占位

const router = createRouter([
    {
        path: '/', element: <App />,
        //  把所有的需要登录的 页面 都作为app的子路由便于进行路由拦截
        children: [
            { path: '/home', element: <Home /> },
            { path: '/fast', element: <Fast /> },
            { path: '/mine/:id', element: <Mine /> },
            { path: '/select/:actionCode', element: <Select /> },
            { path: '/practice', element: <Practice /> },
            { path: '/subjects', element: <Subjects /> },
        ]
    },
    {
        path: '/login', element: <Login />
    }
])

export default router;